<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
import Edit from "./../edit/index";
import Launch from "@/components/launch/index";
export default {
  mixins: [
    Vue.prototype.$vFN.Mixins.Base,
    Vue.prototype.$vFN.Mixins.Page,
    Vue.prototype.$vFN.Mixins.Table,
  ],
  components: {},
  data() {
    return {
      appWindow: window,
      // 页面接口地址
      apiUrl: {
        list: "api/full-discount/pageFullDiscount",
        delete: "api/full-discount/deleteFullDiscount",
        stop: "api/full-discount/stopActivity",
      },
      // 表格查询数据
      mixinTable_tableSearchData: {
        activityName: "",
        activityStatus: "",
      },

      // 表格数据
      // tableData: [],
      data: [],
      // 表格数据删除展示结构
      tableDeleteConfig: {
        columns: [
          {
            label: "活动名称",
            prop: "activityName",
            type: "",
          },
          {
            label: "活动状态",
            prop: "activityStatus",
            type: "",
          },
        ],
      },
    };
  },
  methods: {
    // 打开添加/修改
    editBoxOpen(params_) {
      Edit.init({
        mixinEdit_parent: this,
        mixinEdit_editType: params_.type,
        id: params_.id,
      });
    },
    // 初始化
    async init() {
      this.mixinTable_refreshData();
    },

    // 批量暂停活动
    batchStopAction() {
      console.log(this.mixinTable_selectTableData);
      let ids_ = this.mixinTable_selectTableData.map((item) => {
        return item.id;
      });

      this.stopAction(ids_);
    },

    stopAction(ids_) {
      this.$confirm("确定进行此操作吗？", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        // type: "error",
        dangerouslyUseHTMLString: true,
      })
        .then(async () => {
          let that = this;

          let res = await that.$vFN.Http.post(
            {
              url: this.apiUrl.stop,
              data: {
                ids: ids_,
              },
            },
            window
          );
          if (res._ok) {
            that.mixinTable_refreshData();
            that.$vFN.Tools.messageSuccess("操作成功");
            that.editBoxClose();
          }
        })
        .catch(() => {});
    },
  },

  mounted() {
    this.init();
  },
  activated() {},
};
</script>